import request from '@/utils/request'

// 查询仓库列表列表
export function listWarehouse(query) {
  return request({
    url: '/warehouse/warehouse/list',
    method: 'get',
    params: query
  })
}

// 查询仓库列表详细
export function getWarehouse(warehouseId) {
  return request({
    url: '/warehouse/warehouse/' + warehouseId,
    method: 'get'
  })
}

// 新增仓库列表
export function addWarehouse(data) {
  return request({
    url: '/warehouse/warehouse',
    method: 'post',
    data: data
  })
}

// 修改仓库列表
export function updateWarehouse(data) {
  return request({
    url: '/warehouse/warehouse',
    method: 'put',
    data: data
  })
}

// 删除仓库列表
export function delWarehouse(warehouseId) {
  return request({
    url: '/warehouse/warehouse/' + warehouseId,
    method: 'delete'
  })
}

// 获取库管部门
export function getDept() {
  return request({
    url: '/warehouse/warehouse/dept',
    method: 'get'
  })
}

// 获取仓库主管
export function getUser() {
  return request({
    url: '/warehouse/warehouse/user',
    method: 'get'
  })
}

// 查询库位列表
export function listLocation(query) {
  return request({
    url: '/warehouse/location/listLocation',
    method: 'get',
	params: query
  })
}

// 获取编码
export function getWarehouseCode(code) {
  return request({
    url: '/warehouse/warehouse/getcode?code=' + code,
    method: 'post'
  })
}

// 删除库位列表
export function delLocation(locationId) {
  return request({
    url: '/warehouse/location/' + locationId,
    method: 'delete'
  })
}

// 修改库位列表
export function updateLocation(data) {
  return request({
    url: '/warehouse/location',
    method: 'put',
    data: data
  })
}

// 查询仓库列表详细
export function getLocation(locationId) {
  return request({
    url: '/warehouse/location/' + locationId,
    method: 'get'
  })
}

// 新增库位列表
export function addLocation(data) {
  return request({
    url: '/warehouse/location',
    method: 'post',
    data: data
  })
}

//新增仓库库位
export function addLocationWarehouseCode(data) {
  return request({
    url: '/warehouse/location/addLocationWarehouseCode?locationIds=' + data.locationIds + '&warehouseCode=' + data.warehouseCode,
    method: 'post'
  })
}

// 获取编码
export function getLocationCode(code) {
  return request({
    url: '/warehouse/location/getcode?code=' + code,
    method: 'post'
  })
}

// 获取库位数量
export function findBsWhLocationByCount(data) {
  return request({
    url: '/warehouse/location/findBsWhLocationByCount?warehouseCode=' + data,
    method: 'post'
  })
}

// 根据库位获取商品数量
export function getWhInventoryByWarehouseCode(data) {
  return request({
    url: '/warehouse/location/getLocationCode?locationCode=' + data,
    method: 'post'
  })
}

//停用库位
export function deactivateThatLocation(data,status) {
  return request({
    url: '/warehouse/location/deactivate?locationCode=' + data + '&status=' + status,
    method: 'post'
  })
}


// 库存数量占比
export function selectBsWarehouseQuantity() {
  return request({
    url: '/warehouse/warehouse/quantity',
    method: 'get',
  })
}

// 库存金额占比
export function selectBsWarehouseMoney() {
  return request({
    url: '/warehouse/warehouse/money',
    method: 'get',
  })
}

//根据仓库编号获取库位
export function selectLocation(query){
  return request({
    url: '/warehouse/location/selectLocation?warehouseCode=' + query,
    method: 'get',
  })
}

//根据商品编号和库位编号获取商品库存数量
export function getInventoryNumber(query){
  return request({
    url: '/warehouse/location/getInventory',
    method: 'get',
	params: query
  })
}

export function updateWarehouseCode(data){
  return request({
    url: '/warehouse/location/updateWarehouseCode?warehouseCode='+data,
    method: 'get',
  })
}

//获取文件
export function getAttachment(data){
  return request({
    url: '/warehouse/warehouse/getAttachment?code='+data,
    method: 'get',
  })
}

// //获取文件
// export function selectAll(){
//   return request({
//     url: '/warehouse/warehouse/selectAll,
//     method: 'get',
//   })
// }
